/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <cstdio>
#include <map>
using namespace std;

int main_1009()
{
    map<int,double,greater<int>> poly1,poly2,poly;
    int K,exp,cnt=0;
    double coeff;
    scanf("%d",&K);
    for (int i=0;i<K ;++i )
    {
        scanf("%d%lf",&exp,&coeff);
        poly1[exp]=coeff;
    }
    scanf("%d",&K);
    for (int i=0;i<K ;++i )
    {
        scanf("%d%lf",&exp,&coeff);
        poly2[exp]=coeff;
    }
    for (auto i=poly1.begin();i!=poly1.end() ;++i )
    {
        for (auto j=poly2.begin();j!=poly2.end() ;++j )
        {
            poly[(i->first)+(j->first)]+=(i->second)*(j->second);
        }
    }
    for (auto i=poly.begin();i!=poly.end() ;++i )
    {
        if (i->second!=0.0)
        {
            ++cnt;
        }
    }
    printf("%d",cnt);
    for (auto i=poly.begin();i!=poly.end() ;++i )
    {
        if (i->second!=0.0)
        {
        printf(" %d %.1lf",i->first,i->second);
        }
    }
	return 0;
}
